<?php 

/* this class is used in business model getForm() method */

class BusinessModelForm extends CForm
{
    public function render()
    {    	
        return $this->renderBegin() . $this->renderBody() . $this->renderEnd();
    }

    
	public function renderElement($element)
	{
		if(is_string($element))
		{
			if(($e=$this[$element])===null && ($e=$this->getButtons()->itemAt($element))===null)
				return $element;
			else
				$element=$e;
		}
		if($element->getVisible())
		{
			if($element instanceof CFormInputElement)
			{
				if($element->type==='hidden')
					return "<div style=\"visibility:hidden\">\n".$element->render()."</div>\n";
				else
					return "<div class=\"row field_{$element->name}\">\n".$element->render()."</div>\n";
			}
			else if($element instanceof CFormButtonElement)
				return $element->render()."\n";
			else
				return $element->render();
		}
		else
		{
			if ($element->name =='tblPartnership')
			{
				$output = array(
					'{label}'=> $element->renderLabel(),
					'{input}'=> CHtml::activeCheckBoxList($element->getParent()->getModel(),$element->name,$element->items, array('attributeitem' => 'id','separator'=>'<br>','labelOptions'=>array('style'=>'display:inline'))),
					'{hint}'=>$element->renderHint(),
					'{error}'=>$element->getParent()->showErrorSummary ? '' : $element->renderError(),			
				);
						
				return strtr($element->layout,$output);
			}
			if ($element->name =='tblRevenuestreams')
			{
				$output = array(
					'{label}'=> $element->renderLabel(),
					'{input}'=> CHtml::activeCheckBoxList($element->getParent()->getModel(),$element->name,$element->items, array('attributeitem' => 'id','separator'=>'<br>','labelOptions'=>array('style'=>'display:inline'))),
					'{hint}'=>$element->renderHint(),
					'{error}'=>$element->getParent()->showErrorSummary ? '' : $element->renderError(),			
				);
						
				return strtr($element->layout,$output);
			}
		}
		return '';
	}
	
}
/*
echo $form->checkBoxList($model, 'tblBusinessresources',
            		CHtml::listData(BusinessResources::model()->findAll(), 'id', 'name'),
            		array('attributeitem' => 'id','separator'=>'<br>','labelOptions'=>array('style'=>'display:inline')) );
 */
